package mviewer.model3dLoader;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.HashSet;
import java.util.Set;
import mviewer.types.IModel3d;

public class ModelLoaderFacade {

	private Set<IModel3dLoader> loader = new HashSet<IModel3dLoader>();

	public boolean addLoader(IModel3dLoader loader) {
		return this.loader.add(loader);
	}

	public boolean supports(String file) {
		for (IModel3dLoader l : loader)
			if (l.supports(file))
				return true;
		return false;
	}

	public IModel3d loadModel(String file) throws FileNotFoundException, IOException {
		for (IModel3dLoader l : loader)
			if (l.supports(file))
				return l.loadModel(file);
		throw new IllegalArgumentException("Unsupported file model format given");
	}
}
